package com.chixing.day05_oop;

public class AccountTest {
    public static void main(String[] args) {
        SavingAccount sa1 = new SavingAccount();
        sa1.setAccNo(622288888L);
        sa1.setAccName("smith");

        SavingAccount sa2 =  new SavingAccount(622288888L,"katy","123456",182222222L,100,0);
        System.out.println(sa2 instanceof SavingAccount); //true
        System.out.println(sa2 instanceof Account); // true
        System.out.println(sa2 instanceof Object);// true

        Account sa3 = sa2;
        Account sa4 = new SavingAccount();


        Dog dog =  new Dog();  // this dog is a Dog


        Animal an1 =  new Dog(); //this dog  is a Animal

        Object o1 =  new Dog();

        Animal an2 = new Animal();
      // Dog dog2 = new Animal();  // 编译错误 complier error (syntax error)

        // ClassCastException : 类转转异常
       // Dog dog2 =(Dog) an2; // error 强制类型转换  【an2 在堆内存中 是Animal 类型】

        Dog dog3 =(Dog) an1; // yes  an1 在堆中  new Dog() Dog类型
        System.out.println(dog3 instanceof  Dog);
        System.out.println(dog3 instanceof  Animal);
//new CreditAccount(...)

        long x = 889229932329L;
        int y =(int) x;


        int m = 7788;
        byte n =  (byte)m; // -128 ~ 127
        // n 7788
    }
}


class Animal{}

class Dog extends Animal{}




